package ps.net;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import ps.server.rights.User;

public class ChangeUserRightContent implements PacketContent {
    
    int right = User.RIGHT_NONE;
    String userName = "";
    
    ChangeUserRightContent() {
    }
    
    public ChangeUserRightContent(String userName, int right) {
        this.userName = userName;
        this.right = right;
    }
    
    @Override
    public void writeContent(OutputStream out) throws IOException {
        // write right
        out.write(right);
        
        // write user name
        Packet.writeString(out, userName);
    }
    
    @Override
    public void readContent(InputStream in) throws IOException {
        // read right
        right = in.read();
        
        // read user name
        userName = Packet.readString(in);
    }
    
    @Override
    public String toString() {
        String ret = "[ ChangeUserRight |";
        ret += " userName=" + userName;
        ret += " right=" + right;
        ret += " ]";
        return ret;
    }

    public String getUserName() {
        return userName;
    }
    
    public int getRight() {
        return right;
    }

}
